package com.yupi.springbootinit.bizmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import static com.yupi.springbootinit.bizmq.BiMqConstant.*;

/**
 * @version 1.0
 * @Author moresuo
 * @Date 2024/3/6 23:02
 * @注释
 */
public class BiIntiMain {
    public static void main(String[] args)  {
        try {
            ConnectionFactory factory=new ConnectionFactory();
            factory.setHost("111.229.199.44");
            factory.setUsername("admin");
            factory.setPassword("admin");
            factory.setPort(5672);
            String EXCHANGE_NAME = BI_EXCHANGE_NAME;
            Connection connection = factory.newConnection();
            Channel channel = connection.createChannel();
            channel.exchangeDeclare(EXCHANGE_NAME, "direct");
            String queueName = BI_QUEUE_NAME;
            channel.queueDeclare(queueName, true, false, false, null);
            channel.queueBind(queueName, EXCHANGE_NAME, BI_ROUTING_KEY);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }  finally {
        }
    }
}
